var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
    })(t, e);
}, function(t, e) {
    function i() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, 
    new i());
}), a = this && this.__decorate || function(t, e, i, o) {
    var n, r = arguments.length, c = r < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, i) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(t, e, i, o); else for (var s = t.length - 1; 0 <= s; s--) (n = t[s]) && (c = (r < 3 ? n(c) : 3 < r ? n(e, i, c) : n(e, i)) || c);
    return 3 < r && c && Object.defineProperty(e, i, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameConfig"), s = e("GameData"), c = e("PeakRewardItemView"), l = cc._decorator, d = l.ccclass, u = l.property, p = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.scrollView = null, t.itemView = null, t.count = 3, t.items = [], t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        for (this.scrollView.node.setContentSize(cc.winSize), this.items.push(this.itemView); this.items.length < 2 * this.count; ) {
            var t = cc.instantiate(this.itemView.node), e = t.getComponent(c.default);
            e && (t.parent = this.scrollView.content, this.items.push(e));
        }
        var i = this.getScoreConfigIdx();
        this.scrollView.content.width = this.itemView.node.width * (r.GC.peakRewardList.length - 1) + cc.winSize.width, 
        this.scrollView.content.x = -(i - 1) * this.itemView.node.width - cc.winSize.width / 2;
    }, t.prototype.start = function() {
        this.refresh();
    }, t.prototype.refresh = function() {
        var i = this, t = Math.ceil(-(this.scrollView.content.x + cc.winSize.width / 2) / this.itemView.node.width), o = t > this.count ? t - this.count : 0, n = t + this.count < r.GC.peakRewardList.length ? t + this.count : r.GC.peakRewardList.length - 1;
        this.items.forEach(function(t, e) {
            e += o;
            e <= n ? (t.init(r.GC.peakRewardList[e]), t.node.setPosition(cc.v2(e * i.itemView.node.width + cc.winSize.width / 2, 0)), 
            t.node.active = !0) : t.node.active = !1;
        });
    }, t.prototype.getScoreConfigIdx = function(t) {
        void 0 === t && (t = s.GD.curScore);
        for (var e = 0; e < r.GC.peakScoreConfig.length && t >= r.GC.peakScoreConfig[e].score; ) e++;
        return e;
    }, a([ u(cc.ScrollView) ], t.prototype, "scrollView", void 0), a([ u(c.default) ], t.prototype, "itemView", void 0), 
    a([ u ], t.prototype, "count", void 0), a([ d ], t);
}(cc.Component);

n.default = p;